package com.yx.xinruitu.controller;

import com.yx.xinruitu.controller.base.BaseController;
import com.yx.xinruitu.service.IStaffService;
import com.yx.xinruitu.util.ParameterMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/staff")
public class StaffController extends BaseController {
	
	@Autowired
	private IStaffService staffService;
	

	/**
	 * 排名列表
	 * @return
	 */
	@RequestMapping(value="/orderlist",method=RequestMethod.GET)
	public Object orderlist(Model model){
		ParameterMap map=this.getParameterMap();
		model.addAttribute("result",staffService.getOrderList(map,orderSize,pageNo));
		return "page/staff/orderlist";
	}
	/**
	 * 工会答题统计
	 * @return
	 */
	@RequestMapping(value="/deptlist",method=RequestMethod.GET)
	public Object deptlist(){
		return "page/staff/deptlist";
	}
	/**
	 * 工会答题统计数据
	 * @return
	 */
	@RequestMapping(value="/deptData",method=RequestMethod.GET)
	@ResponseBody
	public Object deptData(){
		return staffService.getdeptList(this.getParameterMap());
	}


	/**
	 * 分页列表
	 * @return
	 */
	@RequestMapping(value="/list",method=RequestMethod.GET)
	public Object list(Model model){
		ParameterMap map=this.getParameterMap();
		if(map.containsKey("pageNo")){
			pageNo=Integer.valueOf(map.get("pageNo").toString());
		}
		map.put("is_delete",0);
		model.addAttribute("result",staffService.getStaffListByPage(map,pageSize,pageNo));
		if(map.containsKey("name")){
			model.addAttribute("name",map.get("name"));
		}
		if(map.containsKey("company")){
			model.addAttribute("company",map.get("company"));
		}
		return "page/staff/list";
	}
	/**
	 * 初赛个人排名
	 * @return
	 */
	@RequestMapping(value="/cslist",method=RequestMethod.GET)
	public Object cslist(Model model){
		ParameterMap map=this.getParameterMap();
		if(map.containsKey("pageNo")){
			pageNo=Integer.valueOf(map.get("pageNo").toString());
		}
		map.put("is_delete",0);
		model.addAttribute("result",staffService.csList(map,orderSize,pageNo));
		if(map.containsKey("name")){
			model.addAttribute("name",map.get("name"));
		}
		return "page/staff/cslist";
	}
	/**
	 * 复赛个人排名
	 * @return
	 */
	@RequestMapping(value="/fslist",method=RequestMethod.GET)
	public Object fslist(Model model){
		ParameterMap map=this.getParameterMap();
		model.addAttribute("result",staffService.fsList(map,orderSize,pageNo));
		return "page/staff/fslist";
	}

	/**
	 * 初赛单位前15排名
	 * @return
	 */
	@RequestMapping(value="/csDeptlist",method=RequestMethod.GET)
	public Object csDeptlist(Model model){
		ParameterMap map=this.getParameterMap();
		if(map.containsKey("pageNo")){
			pageNo=Integer.valueOf(map.get("pageNo").toString());
		}
		map.put("is_delete",0);
		model.addAttribute("result",staffService.csDeptlist(map,orderSize,pageNo));
		if(map.containsKey("name")){
			model.addAttribute("name",map.get("name"));
		}
		return "page/staff/csDeptlist";
	}


	/**
	 * 复赛单位排名
	 * 单位排名为复赛成绩前3总和
	 * @return
	 */
	@RequestMapping(value="/fsDeptlist",method=RequestMethod.GET)
	public Object fsDeptlist(Model model){
		ParameterMap map=this.getParameterMap();
		model.addAttribute("result",staffService.fsDeptlist(map,orderSize,pageNo));
		return "page/staff/fsDeptlist";
	}


	/**
	 * 复赛单位前15排名
	 * @return
	 */
	@RequestMapping(value="/fs_Deptlist",method=RequestMethod.GET)
	public Object fs_Deptlist(Model model){
		ParameterMap map=this.getParameterMap();
		if(map.containsKey("pageNo")){
			pageNo=Integer.valueOf(map.get("pageNo").toString());
		}
		map.put("is_delete",0);
		model.addAttribute("result",staffService.fs_Deptlist(map,orderSize,pageNo));
		if(map.containsKey("name")){
			model.addAttribute("name",map.get("name"));
		}
		return "page/staff/fs_Deptlist";
	}
}
